home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
tagsgen.exe
/
ASMTAG.E
< prev
next >
Wrap
Text File
|
1992-03-29
|
26KB
|
776 lines
/*
EPSHeader
File: asmtag.c
Author: J. Kercheval
Created: Sun, 07/14/1991 17:25:26
*/
/*
EPSRevision History
J. Kercheval Sun, 07/14/1991 20:25:59 creation
J. Kercheval Mon, 07/15/1991 22:47:30 finish finite state machine parser
J. Kercheval Wed, 07/17/1991 21:35:43 add IsMember() and get_token()
J. Kercheval Thu, 07/18/1991 19:57:34 add flags checking
J. Kercheval Sun, 07/21/1991 15:58:56 add comment block support
J. Kercheval Sat, 07/27/1991 21:16:53 remove public post process support
J. Kercheval Sat, 07/27/1991 22:50:49 performance considerations (+10%)
J. Kercheval Sat, 08/10/1991 18:14:46 Speed up IsMember()
J. Kercheval Fri, 09/13/1991 01:17:05 add when_loading() to remap def_srch_case_map[]
J. Kercheval Thu, 10/03/1991 12:27:37 fix logic outputting local labels
J. Kercheval Sat, 10/05/1991 14:06:33 add ASMTagWant defines
*/
/*
* This file implements tagging for .ASM and .INC files which contain 80x86
* assembler in the MASM/TASM syntax. This file defines no new commands and
* is intended to work with the tags package included with V5.0 of Epsilon.
* There is no problem using modified tags packages providing calls are made
* to tags_suffix_???() routines in the same way Epsilon does this and that
* an output routine add_tag() is used. All that should be required is to
* compile and load this file and this module will be used transparently to
* you.
*
* This module implements tagging for UNION, STRUC, MACRO, PROC, LABEL
* keywords as well as for implicit labels (label:) and for data defintions
* (ie. equ, =, dq, dw, db, etc....). The performance cost on a per tag
* basis is negligable, but since more tagging is done, you should expect a
* practical 10%-20% performance hit on a per file basis. This tagger is not
* intended to do all of your work for you but is designed to be used in
* conjunction with the tags generator I have developed and is now available.
* This file implements the same semantic parser as is found in that
* executable. Use the executable in your make file for very fast and
* updated tags. If you have problems finding it, contact me and I can point
* the way...
*
* There is defined at the end of this module a when_loading() function which
* alters the default search case map to allow *correct* (or at least
* consistent sorting with sort routines external to Epsilon. In particular,
* to produce the same sort order as any UNIX, VMS or HP style sort or with
* the tags generator this module is supposed to coexist with this mapping
* must be done. You should see no difference in the location of sorted
* buffers except for lines starting with ^, [, \, ] and _.
*
* This code is dedicated to the public domain with the caveat that Lugaru is
* welcome to use this within their distribution source code which is
* supplied with Epsilon.
*
* Good Tagging,
*
* jbk@wrq.com
*
* John Kercheval
* 127 NW Bowdoin Pl #105
* Seattle, WA 98107-4960
* August 10, 1991
*/
#include <eel.h>
#ifndef BOOLEAN
#define BOOLEAN int
#define TRUE 1
#define FALSE 0
#endif
/* This is a list of the types of tokens you may want to tag. Set them true
* if you want that particular type of tag.
*/
#define ASMTagWantProc TRUE
#define ASMTagWantMacro TRUE
#define ASMTagWantLabel TRUE
#define ASMTagWantStruc TRUE
#define ASMTagWantUnion TRUE
#define ASMTagWantDefine TRUE
/*
* The finite state machine allows the following interesting paths
*
* 1 - Discard, Parse1, Symbol1
* 2 - Discard, Parse1, Parse2, Symbol2
* 3 - Discard, Parse1, Parse2, Define
*
* all the important cases follow one of these paths according to MASM/TASM
* syntax. The exit state is for finish up routine calls and some paths not
* covered here are simple error paths and probably result from syntax errors
*
* enum state { Discard, Parse1, Parse2, Symbol1, Symbol2, Define, Exit };
*/
/*
* emulate an enumerated type for the state machine
*/
#define Discard 0
#define Parse1 1
#define Parse2 2
#define Symbol1 3
#define Symbol2 4
#define Define 5
#define Exit 6
typedef int State;
#define COMMENT_CHAR ';'
#define SYMBOL_SIZE 15
/*----------------------------------------------------------------------------
*
* The symbol lists represent all the symbols we are interested in either
* obtaining or ignoring. The first element of each of these symbol lists is
* a string containing all the first characters within the symbol list. This
* allows faster rejection for IsMember() which is called often.
*
---------------------------------------------------------------------------*/
/* symbols which are not significant for this parser */
char ASM_NOP_Sym[][SYMBOL_SIZE] =
{
"cpbfnwo", /* list of starting characters of symbols
* below */
"c", /* C language declaration */
"pascal", /* PASCAL language declaration */
"basic", /* BASIC language declaration */
"fortran", /* FORTRAN language declaration */
"prolog", /* PROLOG language declaration */
"nolanguage", /* generic language declaration */
"windows", /* WINDOWS exit and entry modifier */
"oddnear", /* overlay modifier */
"oddfar", /* overlay modifier */
"normal", /* normal procedure entry/exit code */
"\0"
};
/* symbols which begin a comment block */
char ASM_comment_block[][SYMBOL_SIZE] =
{
"c", /* list of starting characters of symbols
* below */
"comment", /* begin comment block, next character is
* delimiter */
"\0"
};
/* create the function for determining if a character is a delimiter */
#define IsDelim(c) ( _ASM_delim_table[c] )
/* the indexed table for white space character lookup */
BOOLEAN _ASM_delim_table[256];
/* valid delimiters for this syntax */
char ASM_delim[] = " \t\n;:=.,\"()<>[]*-+/";
/* create the function for determining if a character is a whitespace */
#define IsWhite(c) ( _ASM_white_table[c] )
/* the indexed table for white space character lookup */
BOOLEAN _ASM_white_table[256];
/* whitespace characters */
char ASM_white[] = " \t\v\f";
/* symbols which both are delimiters and a special token, these are
special tokens only when found at the the beginning of a string of
1 or more delimiters */
char ASM_delim_Sym[] = "=:";
/* symbols which fit into the Define state and represent a tagged symbol */
/* state Define depends on the token ":" being at index 1 in this list */
char ASM_def[][SYMBOL_SIZE] =
{
":e=cd", /* list of starting characters of symbols
* below */
":", /* local labels */
"equ", /* equivalence */
"=", /* equivalence */
"catstr", /* concatenated and named strings */
"db", /* named byte data definition */
"dw", /* named word data definition */
"dd", /* named double word data definition */
"dp", /* named 6 byte far pointer data area
* definition */
"df", /* named 6 byte far pointer definition */
"dq", /* named quad word data definition */
"dt", /* named 10 byte data area */
"\0"
};
/* symbols which fit into the Symbol state and represent a tagged symbol */
char ASM_sym[][SYMBOL_SIZE] =
{
"pmlsu", /* list of starting character of symbols
* below */
"proc", /* proced